{% load i18n %}
{% load privacy_tags %}

<!-- BEGIN onboard first build -->

{% if request.user|is_admin:project %}
  <div class="onboard onboard-detail">
    {% if not onboard.build %}
      <h2>{% trans "Start building your documentation" %}</h2>
      <p>
        {% blocktrans trimmed %}
          This project has not been built yet.
          Try building the latest version now,
          or if you would like to build a specific version,
          select the version below and your documentation build will be triggered.
        {% endblocktrans %}
      </p>

      <form method="post" action="{% url "projects_detail" project.slug %}">
        {% csrf_token %}
        <input type="hidden" name="version_slug" value="latest" />
        <input type="submit" value="{% trans "Build latest version" %}" />
      </form>
    {% else %}

      {% if onboard.build.finished %}
        {% if onboard.build.success %}
          {% comment %}Last build passed{% endcomment %}
          <h2>{% trans "Your documentation is ready to use" %}</h2>

          <form method="get" action="{{ project.get_docs_url }}">
            <p>
            {% blocktrans trimmed %}
              Your documentation has been built.
              Ensure your documentation is kept up to date with every commit to
              your repository, by
              <a href="http://docs.readthedocs.io/page/webhooks.html">setting up a webhook</a>.
            {% endblocktrans %}
            </p>

            <input type="submit" value="{% trans "View your documentation" %}"/>
          </form>
        {% else %}
          {% comment %}Last build failed{% endcomment %}
          <h2>{% trans "Your documentation failed to build" %}</h2>

          <form method="get" action="{% url "builds_detail" project_slug=project.slug build_pk=onboard.build.pk %}">
            <p>
            {% blocktrans trimmed %}
              There was a problem building your documentation,
              you can see what went wrong in the build output.
              If you need more help, check out some of the
              <a href="http://docs.readthedocs.io/page/faq.html">problems frequently encountered</a>
              during builds.
            {% endblocktrans %}
            </p>

            <input type="submit" value="{% trans "View build output" %}"/>
          </form>
        {% endif %}
      {% else %}
        
        {% url "builds_detail" project_slug=project.slug build_pk=onboard.build.pk as latest_build_url %}
        <a href="{{ latest_build_url }}"><h2>{% trans "Your documentation is building" %}</h2></a>
        
        <p>
        {% blocktrans trimmed %}
          You'll be able to view your documentation in a minute or two,
          once your project is done building.
        {% endblocktrans %}
        </p>
      {% endif %}

  {% endif %}
  </div>
  {% endif %}

<!-- END onboard import project -->
